package com.example.dryyzx.dao;

import com.example.dryyzx.entity.Customer;
import org.apache.ibatis.jdbc.SQL;

public class CustomerSqlProvider {
    public String insertSelective(Customer record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("customer");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            sql.VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getAge() != null) {
            sql.VALUES("age", "#{age,jdbcType=INTEGER}");
        }
        
        if (record.getSex() != null) {
            sql.VALUES("sex", "#{sex,jdbcType=CHAR}");
        }
        
        if (record.getIdNumber() != null) {
            sql.VALUES("id_number", "#{idNumber,jdbcType=CHAR}");
        }
        
        if (record.getArchivesid() != null) {
            sql.VALUES("archivesId", "#{archivesid,jdbcType=CHAR}");
        }
        
        if (record.getType() != null) {
            sql.VALUES("type", "#{type,jdbcType=CHAR}");
        }
        
        if (record.getCheckinTime() != null) {
            sql.VALUES("checkin_time", "#{checkinTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getDueDate() != null) {
            sql.VALUES("due_date", "#{dueDate,jdbcType=TIMESTAMP}");
        }
        
        if (record.getPhoneNumber() != null) {
            sql.VALUES("phone_number", "#{phoneNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getBirthday() != null) {
            sql.VALUES("birthday", "#{birthday,jdbcType=DATE}");
        }
        
        if (record.getHeight() != null) {
            sql.VALUES("height", "#{height,jdbcType=REAL}");
        }
        
        if (record.getMaritalStatus() != null) {
            sql.VALUES("marital_status", "#{maritalStatus,jdbcType=CHAR}");
        }
        
        if (record.getWeight() != null) {
            sql.VALUES("weight", "#{weight,jdbcType=REAL}");
        }
        
        if (record.getBloodType() != null) {
            sql.VALUES("blood_type", "#{bloodType,jdbcType=CHAR}");
        }
        
        if (record.getRemarks() != null) {
            sql.VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getBedId() != null) {
            sql.VALUES("bed_id", "#{bedId,jdbcType=INTEGER}");
        }
        
        if (record.getNursingLevel() != null) {
            sql.VALUES("nursing_level", "#{nursingLevel,jdbcType=INTEGER}");
        }
        
        if (record.getState() != null) {
            sql.VALUES("state", "#{state,jdbcType=CHAR}");
        }
        
        if (record.getRemainTimes1() != null) {
            sql.VALUES("remain_times_1", "#{remainTimes1,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes2() != null) {
            sql.VALUES("remain_times_2", "#{remainTimes2,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes3() != null) {
            sql.VALUES("remain_times_3", "#{remainTimes3,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes4() != null) {
            sql.VALUES("remain_times_4", "#{remainTimes4,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes5() != null) {
            sql.VALUES("remain_times_5", "#{remainTimes5,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes6() != null) {
            sql.VALUES("remain_times_6", "#{remainTimes6,jdbcType=INTEGER}");
        }
        
        if (record.getHealthKeeperId() != null) {
            sql.VALUES("health_keeper_id", "#{healthKeeperId,jdbcType=INTEGER}");
        }
        
        if (record.getHeadPortrait() != null) {
            sql.VALUES("head_portrait", "#{headPortrait,jdbcType=LONGVARBINARY}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Customer record) {
        SQL sql = new SQL();
        sql.UPDATE("customer");
        
        if (record.getName() != null) {
            sql.SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getAge() != null) {
            sql.SET("age = #{age,jdbcType=INTEGER}");
        }
        
        if (record.getSex() != null) {
            sql.SET("sex = #{sex,jdbcType=CHAR}");
        }
        
        if (record.getIdNumber() != null) {
            sql.SET("id_number = #{idNumber,jdbcType=CHAR}");
        }
        
        if (record.getArchivesid() != null) {
            sql.SET("archivesId = #{archivesid,jdbcType=CHAR}");
        }
        
        if (record.getType() != null) {
            sql.SET("type = #{type,jdbcType=CHAR}");
        }
        
        if (record.getCheckinTime() != null) {
            sql.SET("checkin_time = #{checkinTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getDueDate() != null) {
            sql.SET("due_date = #{dueDate,jdbcType=TIMESTAMP}");
        }
        
        if (record.getPhoneNumber() != null) {
            sql.SET("phone_number = #{phoneNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getBirthday() != null) {
            sql.SET("birthday = #{birthday,jdbcType=DATE}");
        }
        
        if (record.getHeight() != null) {
            sql.SET("height = #{height,jdbcType=REAL}");
        }
        
        if (record.getMaritalStatus() != null) {
            sql.SET("marital_status = #{maritalStatus,jdbcType=CHAR}");
        }
        
        if (record.getWeight() != null) {
            sql.SET("weight = #{weight,jdbcType=REAL}");
        }
        
        if (record.getBloodType() != null) {
            sql.SET("blood_type = #{bloodType,jdbcType=CHAR}");
        }
        
        if (record.getRemarks() != null) {
            sql.SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getBedId() != null) {
            sql.SET("bed_id = #{bedId,jdbcType=INTEGER}");
        }
        
        if (record.getNursingLevel() != null) {
            sql.SET("nursing_level = #{nursingLevel,jdbcType=INTEGER}");
        }
        
        if (record.getState() != null) {
            sql.SET("state = #{state,jdbcType=CHAR}");
        }
        
        if (record.getRemainTimes1() != null) {
            sql.SET("remain_times_1 = #{remainTimes1,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes2() != null) {
            sql.SET("remain_times_2 = #{remainTimes2,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes3() != null) {
            sql.SET("remain_times_3 = #{remainTimes3,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes4() != null) {
            sql.SET("remain_times_4 = #{remainTimes4,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes5() != null) {
            sql.SET("remain_times_5 = #{remainTimes5,jdbcType=INTEGER}");
        }
        
        if (record.getRemainTimes6() != null) {
            sql.SET("remain_times_6 = #{remainTimes6,jdbcType=INTEGER}");
        }
        
        if (record.getHealthKeeperId() != null) {
            sql.SET("health_keeper_id = #{healthKeeperId,jdbcType=INTEGER}");
        }
        
        if (record.getHeadPortrait() != null) {
            sql.SET("head_portrait = #{headPortrait,jdbcType=LONGVARBINARY}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}